package com.common.mysql.resource;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * @auther zhangwj
 * @date 2021/11/27 下午9:57
 */
@Component
public class MysqlEnvironmentPostProcessor implements EnvironmentPostProcessor {

    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        Properties properties = new Properties();
        properties.setProperty("spring.main.allow-bean-definition-overriding", "true");
        environment.getPropertySources().addFirst(new PropertiesPropertySource("common.mysql", properties));
    }
}
